# # -*- coding: utf-8 -*-

class ShowBase(object):
    def show(self, result):
        '''
            # NOTE: yeah, we already shown the move
            # but i want to keep the DefaultMode class

            # should I print the basic explanation here?
            # so, we don't need DefaultMode class anymore
            # the translation is a must show option, so 
            # this makes sense, will consider it later
        '''
        # basic translation, this section is a must show
        for res in result['translation']:
            print res

        if 'basic' in result and 'explains' in result['basic']:
            # basic explanations from youdao dictionary
            for exp in result['basic']['explains']:
                print exp

class MoreInfoMode(ShowBase):
    ''' 
        this mode can support leading "+" sign,
        which gives comprehensive explanation of
        the word to be tranlated 
    '''
    def show(self, result):
        # show basic translation
        super(MoreInfoMode, self).show(result)

        if 'web' in result:
            # explanations from web
            for res in result['web']:
                print res['key'], res['value'][0]

class DefaultMode(ShowBase):
    ''' 
        default mode means simple expalanation like,
        help => 帮助
    '''
    def show(self, result):
        # show basic translation
        super(DefaultMode, self).show(result)
